using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Packaging;

namespace OpenLS.Spreadsheet.Formats
{
    public class Office2007Format: SpreadsheetFormat
    {
        public override SpreadsheetDocument Open(Stream stream)
        {
            return  SpreadsheetDocument.Open(stream);
        }
        public override SpreadsheetDocument Open(string fileName)
        {
            return SpreadsheetDocument.Open(fileName);
        }

        public override void Save(SpreadsheetDocument document, Stream stream)
        {
            Package package = Package.Open(stream, FileMode.Create, FileAccess.ReadWrite);
            document.WritePackage(package);
            package.Close();
                
        }
        public override void Save(SpreadsheetDocument document, string fileName)
        {
            Package package = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite);
            document.WritePackage(package);
            package.Close();
        }

        public override string ClipboardName
        {
            get { return SpreadsheetDataFormats.SpreadsheetDocumentDataFormat; }
        }

        public override IEnumerable<string> Extensions
        {
            get { yield return "xlsx";
                yield return "xlsm";
            }
        }
    }
}